<?php
	$host="localhost"; // Host name
	$username="root"; // Mysql username
	$password=""; // Mysql password
	$db_name="JSU_Database"; // Database name

	// Connect to server and select database.
	$message = mysql_connect($host, $username, $password)or die("cannot connect");
	mysql_select_db($db_name)or die("cannot select DB: ".mysql_error());
	session_start();
	$JNo = $_SESSION['JNo'];
	$selectedClasses = $_POST['selectedClasses'];
	for ($i=0;$i<count($selectedClasses);$i++){
		//echo "<br>".$selectedClasses[$i];
		$result = mysql_query("insert into registration (`StudentJNo`, `CourseID`) values ('$JNo','$selectedClasses[$i]')", $message);
		if (!$result) die(mysql_error($message));
	}header("location:coursePage.php");
?>